Skip to content

Merge links on nodes: create super nodes#1398

Open
mgovers wants to merge 18 commits into
mainfrom
feature/super-nodes
Open

Merge links on nodes: create super nodes#1398
mgovers wants to merge 18 commits into
mainfrom
feature/super-nodes

Conversation

@mgovers
Copy link
Copy Markdown
Member

@mgovers mgovers commented May 13, 2026

Part of #35

This actually creates the topological nodes from the regular nodes

mgovers added 8 commits April 29, 2026 14:23
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers mgovers self-assigned this May 13, 2026
@mgovers mgovers added the feature New feature or request label May 13, 2026
Comment thread power_grid_model_c/power_grid_model/include/power_grid_model/supernodes.hpp Outdated
Comment thread power_grid_model_c/power_grid_model/include/power_grid_model/supernodes.hpp Outdated
Comment on lines +150 to +152
if (link_connected[0] == 0 || link_connected[1] == 0) {
return Idx2D{.group = disconnected, .pos = disconnected};
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about this edge case:
If we have a link that's disconnected on one side, but it's not part of any other super node, and its connected side is then connected to a node to an active line, what will happen to that link? It clearly isn't part of a supernode so it will be excluded from the link solver algorithm, but it will also be excluded from the regular topology. What happens then? Is this expected? We still have to have output for it on the connected side.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be loaded. partially connected branches do contribute to the diagonal elements of the Ybus, but after this whole merging-links-on-nodes ordeal is finished, one of the key assumptions is that links have vanishing impedance and reactance relative to the rest of the grid, so they should get null output.

However, you're right in that that differs from the existing output, in which we assume fixed finite impedance.

@nitbharambe and/or @TonyXiang8787 can you confirm that this is indeed correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-side connected links should not participate on calculations. For the output, if the node at the connected side is energized, the link should also have the output energized=1. Otherwise energized=0. All other quantities (power, current, etc) should be zero.

This is exactly the same behavior as current links.

REQUIRE(topo_node_mapping.n_user_nodes() == comp_topo.n_node);
CHECK(topo_node_mapping.mapping() == IdxVector{0, 0, 1});
}
SUBCASE("Disconnected link => not remapped") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mentioned edge case in my previous comment is similar to this, however, can you add it here as well too? Just to make sure the mapping handles it well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that one is tested and handled correctly, right?

and later on in SUBCASE("Disconnected link => not included in user links") it is explicitly tested that they are disconnected in create_topological_nodes

Comment thread tests/cpp_unit_tests/test_supernodes.cpp
@nitbharambe
Copy link
Copy Markdown
Member

no new comments from me @mgovers

mgovers and others added 10 commits May 26, 2026 12:00
…upernodes.hpp


Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>

Co-authored-by: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com>
Signed-off-by: Martijn Govers <martygovers@hotmail.com>
…alculation_parameters.hpp


Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>

Signed-off-by: Martijn Govers <martygovers@hotmail.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@sonarqubecloud
Copy link
Copy Markdown

@AnkurArohi
Copy link
Copy Markdown

AnkurArohi commented May 28, 2026

Hey @mgovers I would like to understand the concept of super node what is it mathematically are you simply merging the switches or links with low impedance or changing something in jacobian

@mgovers
Copy link
Copy Markdown
Member Author

mgovers commented May 29, 2026

Hey @mgovers I would like to understand the concept of super node what is it mathematically are you simply merging the switches or links with low impedance or changing something in jacobian

the intention is to merge the nodes that are connected by switches and links into one super node, by assuming that links and switches have infinitesimal impedance, and therefore vanishing when compared against normal impedances.

this effectively means that we're splitting up the calculations into a calculation at macro scale (basically the net grid) and separately one at micro scale (within each such supernode). the jacobian then effectively changes structure as a result, because we have less nodes in the net grid. in particular, the unstable sections of the jacobian disappear from the equations.

for the micro-grid within a supernode, we make the same assumption that we currently make in mean that all links have the same impedance.

@AnkurArohi
Copy link
Copy Markdown

Hey @mgovers I would like to understand the concept of super node what is it mathematically are you simply merging the switches or links with low impedance or changing something in jacobian

the intention is to merge the nodes that are connected by switches and links into one super node, by assuming that links and switches have infinitesimal impedance, and therefore vanishing when compared against normal impedances.

this effectively means that we're splitting up the calculations into a calculation at macro scale (basically the net grid) and separately one at micro scale (within each such supernode). the jacobian then effectively changes structure as a result, because we have less nodes in the net grid. in particular, the unstable sections of the jacobian disappear from the equations.

for the micro-grid within a supernode, we make the same assumption that we currently make in mean that all links have the same impedance.

are you trying to say that you are still using the impedance of the switch and link rather than completely ignoring it and in order to do so you are creating another micro jacobian and using mean of all impedances in that switch or line?

To this end I would like to point out that this mean value will still be quite small and can very well lead to instabilities, I have some suggestions

  • Model it as ignored impedance and later provide virtual injections to cater the voltage drop, for state estimation it is important to respect the measurements which may be associated with these units on both sides so modelling it as virtual injection which then takes care of voltage drop is elegant way to handle this
  • Alternatively instead of taking mean you can take the max value (it shouldnt be very different)

@mgovers
Copy link
Copy Markdown
Member Author

mgovers commented May 29, 2026

are you trying to say that you are still using the impedance of the switch and link rather than completely ignoring it and in order to do so you are creating another micro jacobian and using mean of all impedances in that switch or line?

To this end I would like to point out that this mean value will still be quite small and can very well lead to instabilities

  1. In the large (macro-level) jacobian, any contribution of links will no longer exist
  2. On the micro-level jacobian, there are only links, and they are therefore assigned the same constant impedance, or equivalently, only 1's (which is what we do in reality), since the system of equations and its solution are equivalent up to that same constant scale factor. This is well-defined (and the algorithm is already implemented in Merge links on nodes: Entry point #1370 and related)
  3. We then use the macro-level PF/SE solution as known injections to the PF equation on the micro-level grid to distribute the active and reactive power flows through the switches/links

NOTE: we do not model lines with low impedance in this way. lines with low impedance are still treated the same as the current PGM does.

I have some suggestions

* Model it as ignored impedance and later provide virtual injections to cater the voltage drop, for state estimation it is important to respect the measurements which may be associated with these units on both sides so modelling it as virtual injection which then takes care of voltage drop is elegant way to handle this

Can you elaborate? (or maybe @nitbharambe you can jump in here?) Our current intention is to completely neglect the voltage drop over links while aggregating any voltage measurements on the affected nodes (Kalman filter). We also have not supported power and current sensors on links from the start.

* Alternatively instead of taking mean you can take the max value (it shouldnt be very different)

This is i guess similar to what we do

@AnkurArohi
Copy link
Copy Markdown

AnkurArohi commented May 29, 2026

@mgovers I understand now , so using the micro logic is not solving the problem of low impedance on links, switches, lines, but thats ok because this is primarily an issue for the transmission state estimation.
In this case, instead of complexing the logic with micro part, it would be fine to assume the fixed 1 value by another realistic one directly.

@mgovers
Copy link
Copy Markdown
Member Author

mgovers commented May 29, 2026

Exactly.

Maybe out of personal interest, can you explain in what way transmission grids differ from distribution grids here?

@nitbharambe
Copy link
Copy Markdown
Member

nitbharambe commented May 29, 2026

to cater the voltage drop,

Voltage drop between?

Maybe the term "impedance" is being misrepresented. Summarizing whole feature:

We basically dissolve links into a single "supernode". Then perform usual PF or SE only on the higher level grid without any link components. This leaves us with voltages and injections from/to normal nodes and the supernodes.
Then within a supernode, we assume power flows equally through all links. Based on this micro-level topology, we redistribute the injection flows to these links. The voltage result of all nodes contained within this supernode is given out equal.

Hence we do away with the old way of assuming link with low impedance and resolve the stability issue.

@AnkurArohi
Copy link
Copy Markdown

Exactly.

Maybe out of personal interest, can you explain in what way transmission grids differ from distribution grids here?

Absolutely, so in distribution grids the impedance has a lower X/R ratio in comparision to the transmission grid and is usually also less metered at switches or bus couplers.
Hence this usecase has less relevance. BUT its an industry problem to solve the cases when there is a measurement at bus coupler which state estimation should use, this improves the observability (2*no._of_meas -1) but since the switches have low or very very low impedance the solvers model it as a diect conneciton to eradicate inversion and Jacobian issues (this is what you are also solving but , using micro node you are simply merging it and provising assumptive impedance)

@AnkurArohi
Copy link
Copy Markdown

AnkurArohi commented May 29, 2026

to cater the voltage drop,

Voltage drop between?

Maybe the term "impedance" is being misrepresented. Summarizing whole feature:

We basically dissolve links into a single "supernode". Then perform usual PF or SE only on the higher level grid without any link components. This leaves us with voltages and injections from/to normal nodes and the supernodes. Then within a supernode, we assume power flows equally through all links. Based on this micro-level topology, we redistribute the injection flows to these links. The voltage result of all nodes contained within this supernode is given out equal.

Hence we do away with the old way of assuming link with low impedance and resolve the stability issue.

voltage drop on the ends of switches is always there in reality, switch and links should have drops even if very very very low.
whats the definition of link in here? Why cant we simply merge the nodes and run one power flow or SE

@mgovers
Copy link
Copy Markdown
Member Author

mgovers commented May 29, 2026

@TonyXiang8787 i think your input is also valuable here.

@TonyXiang8787
Copy link
Copy Markdown
Member

Hi @AnkurArohi,

Thanks for your question and fruitful discussion. While many points have been addressed by @nitbharambe and @mgovers, I try to elaborate a bit at conceptual level.

Purpose of link in PGM

Link in PGM is a conceptual component. It allows user to create a node-to-node interconnection where the user wish ignore the impedance and voltage drop. Realistically, this basically means switches, inter-bus couplings, or any short conductors. If user wish to model these interconnection and ignore the impedance/voltage drop, they should uselink.

On the other hand, if user does want to model the (real measured) impedance of a switch (or bus coupling, or similar), they should model it as a line. Line itself, is also a conceptual component. It means anything with a defined impedance.

Current implementation of link in PGM

In current internal implementation, the link is just modeled as a super small impedance and participate PF, SE, and SC calculations as a regular line. This is less ideal, but works in many cases. Sometimes it results in numerical instability due to the super small impedance, thus super large admittance.

However, if you try to put power/current sensor in links for SE, the calculation will not converge due to ill-conditioned system. So we explicitly forbid sensors on links. This is a limitation in PGM. And yes, for your TSO related use cases, where measurements are on bus-coupling, or switches, those measurements cannot be properly represented in PGM due to this limitation.

Proposed new feature: merging nodes into super node

So the new feature #35 is about to merge nodes which are connected by links, into super node. And links disappear entirely in the actual PF, SE, and SC calculations. The mathematical core does not see links at all. After the calculation, we still need to put some results into links, that's the micro-grid part @mgovers and @nitbharambe are referring. It is merely a post processing to distribute power/current into links.

NOTE: since links are removed entirely in mathematical core, there can still be no sensors on links. This means your TSO use-case (measurement on bus-coupling) will still not be calculated by PGM.

Further future feature: sensors on links

After #35 is done, we will further think about if and how it is possible to model sensors on links for SE. My gut feeling is that this should still be possible. But that require a long-term thinking and more mathematical consideration. This is a long-term ambition which will only be considered after #35.

@AnkurArohi
Copy link
Copy Markdown

AnkurArohi commented May 29, 2026

@TonyXiang8787 that makes my guess clear this here is a post processing result handling part and also the concept of using super node does not solve the inherent problem of impedance less or extremely low impedance based lines and switches with measurements.
I am not demeaning the work here but just want to see and understand what the concept is ,gap is and what the usability is

The industry needs those kind of ideas and mathematical solution which would handle these scenarios with precision and in case that we want to say PGM is also the tool for TSO or mixed DSO TSO networks. (we talked about this shortly at the summit)

Great work
I have ideas and i think also a solution PR for the cases of measurements on switches with low impedance and its handling for SE and PF without illconditioning

happy to share if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants